package me.zhengjie.modules.system.service.dto

import cn.hutool.core.bean.BeanUtil
import cn.hutool.core.bean.copier.CopyOptions
import com.fasterxml.jackson.annotation.JsonTypeInfo
import com.fasterxml.jackson.annotation.JsonTypeName
import me.zhengjie.common.annotation.Query
import me.zhengjie.common.utils.JacksonUtil
import org.apache.commons.lang3.builder.ToStringBuilder


/**
 * 公共查询类
 */
@JsonTypeName("DictQueryCriteria")
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS)
data class DictQueryCriteria (
    // 多字段模糊
    @Query(blurry = "name,remark")
    var blurry: String? = null
){
    annotation class Update

    companion object {
        fun fromJson(json: String): DictQueryCriteria? {
            val obj=JacksonUtil.parseObject(json, DictQueryCriteria::class.java)!!
            return when(obj){
                is DictQueryCriteria-> obj
                else -> null
            }
        }
    }

    fun tojson():String? {
        return JacksonUtil.toJSONString(this)
    }

    fun copy(source: DictQueryCriteria?) {
        BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true))
    }
}